<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@include file="/resource/common/taglib.jspf"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>${SESSION_COMPANY}-系统用户管理</title>
<%@include file="/resource/common/jquery.jspf"%>
<%@include file="/resource/common/commonCss.jspf"%>
<%@include file="/resource/common/bootstrap.jspf"%>
<%@include file="/resource/common/validate.jspf"%>
<%@include file="/resource/common/showLoading.jspf"%>
<%@include file="/resource/common/commonJs.jspf"%>
<%@include file="/resource/common/kindeditor.jspf"%>

<script type="text/javascript">
	var PATH = "${ctx}";
	//初始在线编辑器
    ShowEditorHtml("#description", "word_count");
</script>

<script type="text/javascript">
	$(document).ready(function() {
		$("#form1").validate({
			rules : {
				username : {
					required : true,
					remote : {
						url : "sysUserIsExists.do", //后台处理程序
						type : "post", //数据发送方式
						dataType : "json", //接受数据格式   
						data : { //要传递的数据
							username : function() {
								return $("#username").val();
							}
						}
					}
				},
				password : {
					required : true,
					minlength : 6,
					maxlength : 18
				},
				confirm_password : {
					required : true,
					minlength : 6,
					maxlength : 18,
					equalTo : "#password"
				},
				contact : {
					required : true,
					minlength : 2,
					maxlength : 25
				},
				tel : {
					required : true,
					minlength : 11,
					maxlength : 11
				},
				email : {
					required : true,
					email : true
				},
			},
			messages : {
				username : {
					required : "请输入帐号",
					minlength : "帐号长度不能小于4个字符",
					remote : "帐号已经被注册，请重新换一个."
				}
			},
			errorElement : "em",
			errorClass : "validate_error"
		});
	});
</script>
</head>
<body>
	<div id="body-wrapper">
		<div id="main-content">
			<div class="content-box">
				<div class="content-box-header">
					<h3 class="panel-title">新增系统用户</h3>
					<ul class="content-box-tabs" >
						<a href="javascript:history.go(-1);" class="btn btn-default" style="padding-bottom: 0px;padding-top: 0px;line-height: 25px;margin-top: -5px;">返回</a>
					</ul>
					<div class="clear"></div>
				</div>
				<div class="content-box-content">
					<div class="tab-content default-tab" id="tab1">
						<fieldset>
							<form:form id="form1" name="form1" method="post" class="form-horizontal" action="addSysUser.do">
								<div class="row">
									<div class="col-md-6" >
										<div class="form-group">
											<input type="hidden" id="uid" name="uid" value="${user.uid}">
											<label class="col-sm-2 control-label">帐号：<span style="color: red">*</span></label>
											<div class="col-sm-8">
												<c:choose>
													<c:when test="${empty user }"><input type="text" class="form-control input-sm" id="username" name="username" value="${ user.username }" placeholder="帐号" /></c:when>
													<c:otherwise><input type="text" class="form-control input-sm" id="username" name="username" value="${ user.username }" placeholder="帐号" readonly="readonly"/></c:otherwise>
												</c:choose>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-2 control-label">手机：<span style="color: red">*</span></label>
											<div class="col-sm-8">
												<input type="text" class="form-control input-sm" id="tel" name="tel" value="${ user.tel }" placeholder="手机"/>
											</div>
										</div>
										<c:if test="${empty user }">
											<div class="form-group">
												<label class="col-sm-2 control-label">密码：<span style="color: red">*</span></label>
												<div class="col-sm-8">
													<input type="password" class="form-control input-sm" id="password" name="password" value="" placeholder="密码"/>
												</div>
											</div>
										</c:if>
									</div>
									<div class="col-md-6" >
										<div class="form-group">
											<label class="col-sm-2 control-label">联系人：<span style="color: red">*</span></label>
											<div class="col-sm-8">
												<input type="text" class="form-control input-sm" id="contact" name="contact" value="${ user.contact }" placeholder="联系人"/>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-2 control-label">Email：<span style="color: red">*</span></label>
											<div class="col-sm-8">
												<input type="text" class="form-control input-sm" id="email" name="email" value="${ user.email }" placeholder="email"/>
											</div>
										</div>
										<c:if test="${empty user }">
											<div class="form-group">
												<label class="col-sm-2 control-label">确认密码：<span style="color: red">*</span></label>
												<div class="col-sm-8">
													<input type="password" class="form-control input-sm" id="confirm_password" name="confirm_password" value="" placeholder="验证密码"/>
												</div>
											</div>
										</c:if>
									</div>
								</div>
								<div class="row">
									<div class="col-md-12" >
										<div class="form-group">
											<label class="col-sm-1 control-label">状态：<span style="color: red">*</span></label>
											<div class="col-sm-10">
												 <select id="enable" name="enable">
													<option value="1" <c:if test="${user.enable==1 }">selected="selected"</c:if>>启用</ption>
													<option value="0" <c:if test="${user.enable==0 }">selected="selected"</c:if>>禁用</option>
												</select>
											</div>
										</div>
										<div class="form-group">
											<label class="col-sm-1 control-label">描述：</label>
											<div class="col-sm-10">
												 <textarea id="description" name="description" style="width:100%; height: 300px; visibility: hidden;">${ user.description }</textarea>
											您当前输入了 <span class="word_count">0</span>
											个文字。（字数统计包含纯文本、IMG、EMBED，不包含换行符，IMG和EMBED算一个文字。
											</div>
										</div>
									</div>
								</div>
								<shiro:hasPermission name="SysUser:SYS_ADD">
									<hr>
									<div class="row">
										<div class="col-md-12" >
											<div class="form-group">
												<label class="col-sm-1 control-label"></label>
												<div class="col-sm-10">
													 <input type="submit" class="btn btn-primary" value="确认提交" style="width: 100%; height: 50px;cursor: pointer" />
												</div>
											</div>
										</div>
									</div>
								</shiro:hasPermission>
							</form:form>

						</fieldset>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</body>
</html>